package JDBC;

import JDBC.utils.GetConnectionUtils;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.sql.Connection;
import java.sql.PreparedStatement;

public class WriteClass {
    public static void main(String[] args) throws Exception {
        BufferedInputStream bisAlbum = new BufferedInputStream(new FileInputStream("src/main/java/薛之谦-天外来物.png"));
        BufferedInputStream bisMusic = new BufferedInputStream(new FileInputStream("src/main/java/薛之谦-天外来物.mp3"));


        Connection cnt = GetConnectionUtils.getConnection();

        String sql = """
                insert into music_test (name, singer, album_cover, audio) values (?,?,?,?);
                """;

        PreparedStatement preSta = cnt.prepareStatement(sql);

        preSta.setString(1, "天外来物");
        preSta.setString(2, "薛之谦");
        preSta.setBlob(3, bisAlbum);
        preSta.setBlob(4, bisMusic);

        int line = preSta.executeUpdate();

        System.out.println(line);


    }
}
